#include "songinfomodel.h"
#include <qdebug.h>

SongInfoModel::SongInfoModel(QObject *parent)
	: QAbstractListModel(parent)
{}

SongInfoModel::~SongInfoModel()
{}

int SongInfoModel::rowCount(const QModelIndex & parent) const
{
	return parent.isValid() ? 0 : m_songContent.size();
}

int SongInfoModel::columnCount(const QModelIndex& parent) const
{
	return parent.isValid()? 0 : 1;
}

QVariant SongInfoModel::data(const QModelIndex& index, int role) const
{
	if (!index.isValid())
		return QVariant();

	if (index.row() >= m_songContent.size() || index.row() < 0)
		return QVariant();

	if (role == Qt::DisplayRole) 
	{
		return m_songContent[index.row()]->getMuiscName();
	}

	return QVariant();
}


KSongWebInfo* SongInfoModel::getSongInfo(const QModelIndex& index)
{
	return m_songContent[index.row()];
}

void SongInfoModel::setModelData(QVector<KSongWebInfo*> content)
{
	beginResetModel();
	m_songContent = content;
	endResetModel();
}
